class Outlet : public Device {
public:
    explicit Outlet(const std::string& config) {
        Json::Value params;
        Json::Reader().parse(config, params);
        powerState = params.get("initial_state", false).asBool();
    }
    void executeCommand(const std::string& command) override {
        std::lock_guard<std::mutex> lock(deviceMutex);
        Json::Value cmd;
        Json::Reader().parse(command, cmd);
        if (cmd["action"] == "toggle") {
            powerState = !powerState;
        } else if (cmd["action"] == "set_power") {
            powerState = cmd["state"].asBool();
        }
        
        updatePowerConsumption();
    }
    std::string getStatus() const override {
        Json::Value status;
        status["type"] = "Outlet";
        status["power_state"] = powerState;
        status["power_consumption"] = currentPower;
        return Json::FastWriter().write(status);
    }
private:
    bool powerState = false;
    float currentPower = 0.0f;
    void updatePowerConsumption() {
        // 模拟功率计算
        currentPower = powerState ? 1500.0f : 0.0f; // 1500瓦特
    }
};